package com.example.liwushuo;

import com.example.liwushuo.utils.Utils;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;

public class SplashActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		ImageView image = new ImageView(getApplicationContext());
		
		image.setImageResource(R.drawable.splash);
		image.setScaleType(ScaleType.CENTER_CROP);
		
		setContentView(image);
		new Thread() {

			@Override
			public void run() {
				try {
					sleep(2 * 1000);
					
					boolean isFrist = Utils.isFrist(getApplicationContext());
					Intent intent = null;
					if (isFrist) {
						intent = new Intent(SplashActivity.this,
								WelcomeActivity.class);
					} else {
						intent = new Intent(getApplicationContext(),
								MainActivity.class);
					}
					startActivity(intent);
					finish();

				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}.start();

	}

}
